<#include "/WEB-INF/views/admin/common/layout/__mainlayout.html">
<#include "/WEB-INF/views/admin/common/__pagination.html">
<#assign navLink='admin:sys:res:list' />
<#assign pageCss>
<link rel="stylesheet" href="${ctx}/resource/validationengine/css/validationEngine.jquery.css">
</#assign>
<#assign pageScript>
<script type="text/javascript" src="${ctx}/resource/validationengine/js/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/resource/validationengine/js/jquery.validationEngine.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#addBtn").click(function(){
		layer.open({
			title:'添加资源',
		    type: 2,
		    area: ['800px', '600px'],
		    scrollbar: false,
		    content: '${ctx}/admin/sys/res/add_edit',
		    end : function() {
				window.location.reload();
			}
		});
	});
});

function editRes(id){
	layer.open({
		title:'编辑资源',
	    type: 2,
	    area: ['800px', '600px'],
	    scrollbar: false,
	    content: '${ctx}/admin/sys/res/add_edit?id=' + id,
	    end : function() {
			window.location.reload();
		}
	});
}
function deleteRes(id) {
	$.ajax({
		type : "POST",
		url : "${ctx}/admin/sys/res/delete",
		data : {
			"id" : id
		},
		success : function(result) {
			if (result.isSuccess) {
				layer.msg(result.msg, {
					icon : 1,
					time : 1000,
					end : function() {
						window.location.reload();
					}
				});
			} else {
				layer.msg(result.msg, {
					time : 1000,
					icon : 2
				});
			}

		}
	});
}
</script>
</#assign>
<@mainlayout>
<div class="row-content am-cf">
	<div class="row">
		<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
			<div class="widget am-cf">
				<div class="widget-head am-cf">
					<div class="widget-title am-fl">资源列表</div>
					<div class="widget-function am-fr">
						<a href="javascript:;" class="am-icon-cog"></a>
					</div>
				</div>
				<div class="widget-body  widget-body-lg am-fr">
				<div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
						<div class="am-form-group">
							<div class="am-btn-toolbar">
								<div class="am-btn-group am-btn-group-xs">
								<@hasperm key='admin:sys:res:save'>
									<button type="button" class="am-btn am-btn-default am-btn-success" id="addBtn">
										<span class="am-icon-plus"></span> 新增
									</button>
								</@hasperm>
								</div>
							</div>
						</div>
					</div>
					<form action="${ctx}/admin/sys/res/list/" method="post">
						<div class="am-u-sm-12 am-u-md-12 am-u-lg-3 am-fr">
							<div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
								<input type="text" class="am-form-field " name="search" value="${search}" placeholder="请输入要搜索的名称"> 
									<span class="am-input-group-btn">
									<button
										class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"
										type="submit">
									</button>
								</span>
							</div>
						</div>
					</form>
				<div class="am-u-sm-12">
                  <table width="100%" class="am-table am-table-compact tpl-table-black " id="example-r">
                      <thead>
                          <tr>
                              <th>ID</th>
                              <th>名称</th>
                              <th>地址</th>
                              <th>KEY</th>
                              <th>描述</th>
                              <th>图标</th>
                              <th>排序</th>
                              <th>类型</th>
                              <th>修改时间</th>
                              <th>状态</th>
                              <th>操作</th>
                          </tr>
                      </thead>
                      <tbody>
                      	<#list pageList.list as res>
                          <tr class="gradeX">
                              <td>${res.id!}</td>
                              <td>${res.name!}</td>
                              <td>${res.url!}</td>
                              <td>${res.key!}</td>
                              <td>${res.des!}</td>
                              <td>${res.iconCls!}</td>
                              <td>${res.seq!}</td>
                              <td>
                              	<#if res.type == 1>菜单<#else>按钮</#if>
                              </td>
                              <td>${res.modifydate!}</td>
                              <td>
                              	<#if res.enabled == 1><font class="am-text-success">启用</font>
                              	<#else><font class="am-text-danger">禁用</font>
                              	</#if>
                              </td>
                              <td>
                                  <div class="tpl-table-black-operation">
                                  <@hasperm key='admin:sys:res:save'>
                                      <a href="javascript:editRes('${res.id}');">
                                          <i class="am-icon-pencil"></i> 编辑
                                      </a>
                                  </@hasperm>
                                  <@hasperm key='admin:sys:res:delete'>
                                      <a href="javascript:deleteRes('${res.id}');" class="tpl-table-black-operation-del">
                                          <i class="am-icon-trash"></i> 删除
                                      </a>
                                  </@hasperm>
                                  </div>
                              </td>
                          </tr>
                          </#list>
                          <!-- more data -->
                      </tbody>
                  </table>
              </div>
              <@pagination page=pageList url='/admin/sys/res/list?' />
              </div>
			</div>
		</div>
	</div>
</div>
</@mainlayout>

